﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace mozhi.smarterp.Finance.Migrations
{
    public partial class _202505132125 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MozhiPayment_Currency_CurrencyId",
                table: "MozhiPayment");

            migrationBuilder.DropForeignKey(
                name: "FK_MozhiPaymentItem_ExpenseItem_ExpenseItemId",
                table: "MozhiPaymentItem");

            migrationBuilder.DropForeignKey(
                name: "FK_MozhiPaymentItem_Product_ProductId",
                table: "MozhiPaymentItem");

            migrationBuilder.DropTable(
                name: "Currency");

            migrationBuilder.DropTable(
                name: "ExpenseItem");

            migrationBuilder.DropTable(
                name: "Product");

            migrationBuilder.DropIndex(
                name: "IX_MozhiPaymentItem_ExpenseItemId",
                table: "MozhiPaymentItem");

            migrationBuilder.DropIndex(
                name: "IX_MozhiPaymentItem_ProductId",
                table: "MozhiPaymentItem");

            migrationBuilder.DropIndex(
                name: "IX_MozhiPayment_CurrencyId",
                table: "MozhiPayment");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Currency",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Activated = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Code = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    ExchangeRate = table.Column<decimal>(type: "decimal(65,30)", nullable: false),
                    Name = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Currency", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "ExpenseItem",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Activated = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Code = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Name = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_ExpenseItem", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "Product",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Activated = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Assetable = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    BasicUnitId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
                    Code = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    DefatultTaxRateId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    DefaultSupplierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
                    Model = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Name = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Outsourceable = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Producible = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Purchasable = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Saleable = table.Column<bool>(type: "tinyint(1)", nullable: false),
                    Type = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Product", x => x.Id);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_MozhiPaymentItem_ExpenseItemId",
                table: "MozhiPaymentItem",
                column: "ExpenseItemId");

            migrationBuilder.CreateIndex(
                name: "IX_MozhiPaymentItem_ProductId",
                table: "MozhiPaymentItem",
                column: "ProductId");

            migrationBuilder.CreateIndex(
                name: "IX_MozhiPayment_CurrencyId",
                table: "MozhiPayment",
                column: "CurrencyId");

            migrationBuilder.AddForeignKey(
                name: "FK_MozhiPayment_Currency_CurrencyId",
                table: "MozhiPayment",
                column: "CurrencyId",
                principalTable: "Currency",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_MozhiPaymentItem_ExpenseItem_ExpenseItemId",
                table: "MozhiPaymentItem",
                column: "ExpenseItemId",
                principalTable: "ExpenseItem",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_MozhiPaymentItem_Product_ProductId",
                table: "MozhiPaymentItem",
                column: "ProductId",
                principalTable: "Product",
                principalColumn: "Id");
        }
    }
}
